package com.lzy.product.service.impl;

import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.product.dao.MemberCouponsMapperExt;
import com.lzy.product.dtos.MemberCouponsDto;
import com.lzy.product.entity.MemberCoupons;
import com.lzy.product.service.MemberCouponsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 会员卡券宝详情服务
 * Created by WIN7 on 2017/12/29.
 */
@Component
public class MemberCouponsServiceImpl implements MemberCouponsService {

    @Autowired
    private MemberCouponsMapperExt memberCouponsMapperExt;

    @Override
    public Long insert(MemberCouponsDto dto) {
        MemberCoupons memberCoupons = DozerUtils.map(dto, MemberCoupons.class);
        return memberCouponsMapperExt.insertSelective(memberCoupons) > 0 ? memberCoupons.getId() : 0;
    }

    @Override
    public Boolean update(MemberCouponsDto dto) {
        return memberCouponsMapperExt.updateByPrimaryKeySelective(DozerUtils.map(dto, MemberCoupons.class)) > 0;
    }

    @Override
    public Boolean delete(Long id) {
        return null;
    }

    @Override
    public Boolean remove(Long id) {
        return null;
    }

    @Override
    public MemberCouponsDto findById(Long id) {
        return DozerUtils.map(memberCouponsMapperExt.selectByPrimaryKey(id), MemberCouponsDto.class);
    }

    @Override
    public List<MemberCouponsDto> query(MemberCouponsDto dto) {
        return null;
    }

    @Override
    public MemberCouponsDto findByMemberId(Long memberId) {
        return memberCouponsMapperExt.findByMemberId(memberId);
    }

    @Override
    public MemberCouponsDto findByMemberIdAndType(Long memberId, Integer type) {
        return memberCouponsMapperExt.findByMemberIdAndType(memberId, type);
    }
}
